<include file="nav:header"/>
<div class="container-fluid">
    <script type="text/javascript">
        function add() {
                layer.open({
                    type: 2,
                    skin: 'layui-layer-lan',
                    title: ['ئۇلانما سەھىپە قوشۇش', 'background:#1E9FFF;text-align: center'],
                    fix: false,
                    shadeClose: true,
                    maxmin: true,
                    area: ['30%', '50%'],
                    content: "{:U('LinkClassify/add')}"
                    //end: function () {           //关闭弹出层触发
                    //    location.reload();       //刷新父界面，可改为其他
                    //}
                })
            }
        function edit(id,url) {
            layer.open({
                type: 2,
                skin: 'layui-layer-lan',
                title: ['ئۇلانما سەھىپە قوشۇش', 'background:#1E9FFF;text-align: center'],
                fix: false,
                shadeClose: true,
                maxmin: true,
                area: ['30%', '50%'],
                content: ""
                //end: function () {           //关闭弹出层触发
                //    location.reload();       //刷新父界面，可改为其他
                //}
            });
        }
    </script>
    <div class="row">
        <include file="Left:left-Common"/>
        <!-- right -->
        <div class="col-md-10 right">
            <div class="page-header" style="margin-right: 15px">
                <h3>{$page_title}</h3>
            </div>
            <div class="col-md-12">
                <div class="btn-group " role="group" aria-label="Large button group">
                    <a href="{:U('LinkClassify/index')}" type="button" class="btn btn-default">بارلىق سەھىپە</a>
                    <a href="javascript:add();" type="button" class="btn btn-default">سەھىپە قوشۇش</a>
                </div>
                <!--所有分类-->
                <br><br>
                <table class="table table-bordered">
                    <thead>
                    <tr class="info">
                        <th width="50">CID</th>
                        <th>سەھىپە نامى</th>
                        <th width="60">تەرتىبى </th>
                        <th style="text-align: center">ھالىتى</th>
                        <th style="text-align: center">مەشغۇلات</th>
                    </tr>
                    </thead>
                    <tbody>
                        <foreach name="classifys" item="c">
                            <tr class="classifys active">
                                <td>{$c['id']}</td>
                                <td style="font-size: 15px">
                                    <if condition="$c['lavel'] neq 0">{$c.lavel|_repeat}┘─</if>
                                    &nbsp;{$c.name}
                                </td>
                                <td><input onchange="_sort(this,{$c['id']})" class="form-control" type="text" value="{$c['sort']}" ></td>
                                <td style="text-align: center">
                                    <if condition="$c['status'] eq 1">
                                        <span style="margin-top: 6px;display: inline-block;"  onclick="_status(this,0,{$c['id']})"  class="btn btn-success btn-xs kaiguan">ئوچۇق</span>
                                        <else/>
                                        <span style="margin-top: 6px;display: inline-block;" onclick="_status(this,1,{$c['id']})" class="btn btn-danger btn-xs kaiguan">تاقاق</span>
                                    </if>
                                </td>
                                <td style="text-align: center">
                                    <a  style="margin-top: 6px;display: inline-block;" href="{:U('LinkClassify/edit',array('id'=>$c['id']))}" class="btn btn-success btn-xs ">تەھرىرلەش</a>
                                    <a  style="margin-top: 6px;display: inline-block;" href="javascript:del({$c['id']});" class="btn btn-danger btn-xs">ئۆچۈرۈش</a>
                                </td>
                            </tr>
                        </foreach>
                    </tbody>
                </table>
                <if condition="$count gt  $meige">
                    <div class="page_ye">
                        <dl>
                            <dd>جەمئى {$count} تال ئۇچۇر بار</dd>
                        </dl>
                        <!--分页-->
                        {$page}
                        <div style="clear:both;height: 2px;"></div>
                    </div>
                </if>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //删除分类
    function del(id) {
        layer.confirm('بۇ ئۇچۇرنى راستىنلا ئۆچۈرەمسىز ؟', {
            title:"سېستىما ئەسكەرتىشى",
            btn: ['ھەئە','ياق'] //按钮
        }, function(){
            $.ajax({
                type:"post",
                url:"{:U('LinkClassify/del')}",
                dataType:"json",
                data:{"id":id},
                success:function (phpdata) {
                    if(phpdata.status==1){
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 6,
                            skin: 'layer-ext-moon',
                            time:800
                        });
                        window.location=location;
                    }else{
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 5,
                            skin: 'layer-ext-moon',
                            time:1000
                        });
                    }
                }
            })
        });

    }
    //分类状态
    function _status(obj,status,id) {
        if(status=='0'){
            $(obj).removeClass("btn-success");
            $(obj).addClass("btn-danger");
            $(obj).text("تاقاق")
        }else {
            $(obj).removeClass("btn-danger");
            $(obj).addClass("btn-success");
            $(obj).text("ئوچۇق")
        }
        $.ajax({
            type:"post",
            url:"{:U('LinkClassify/sortStatus')}",
            dataType:"json",
            data:{"id":id,"status":status},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:400
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    $(function () {
        $('.classifys').hover(function () {
            $(this).addClass('info');
        },function () {
            $(".classifys").removeClass('info');
        })
    })

</script>
<include file="nav:footer"/>